﻿@using ZoomLa.Common
@using ZoomLa.BLL
@using ZoomLa.Model
@model ZoomLa.Model.M_ClassRoom
@{

}
@section head{
    <link type="text/css" href="/dist/css/bootstrap-switch.min.css" rel="stylesheet" />
    <title>添加班级</title>
}
@section content{
<div id="BreadDiv" class="container-fluid mysite">
    <div class="row">
        <ol class="breadcrumb navbar-fixed-top">
            <li><a href='@(CustomerPageAction.customPath2)Main.aspx'>工作台</a></li>
            <li><a href='Papers_System_Manage'>教育模块</a></li>
            <li><a href='ClassRoomManage'>班级管理</a></li>
            <li class='active'>添加班级</li>
        </ol>
    </div>
</div>
<form method="post" action="@MVCHelper.GetAction("ClassRoom_Add",Request)" onsubmit="return CheckData();">
    <table class="table table-striped table-bordered table-hover">
        <tr>
            <td class="tdleft"><strong>班级名称:</strong></td>
            <td>
                @Html.TextBoxFor(m => m.RoomName, new { @class = "form-control text_300" })
            </td>
        </tr>
        <tr>
            <td class="td_l tdleft"><strong>所属学校:</strong></td>
            <td>
                <div class="input-group text_405">
                    <input type="text" id="SchoolName_T" name="SchoolName_T" value="@ViewBag.schName" class="form-control" />
                    <span class="input-group-btn">
                        <input type="button" class="btn btn-primary" onclick="ShowSchool();" value="填写或选择学校" />
                    </span>
                </div>
                <span style="color:green;display:inline-block;">*填入的学校不存在则创建新学校</span>
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>班级年级:</strong></td>
            <td>
                @Html.DropDownListFor(m => m.Grade, ViewBag.gradelist as SelectList, new { @class = "form-control text_300" })
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>班主任:</strong></td>
            <td>
                <div class="input-group text_300">
                    <input type="text" id="Manager_T" value="@ViewBag.teaName" class="form-control"/>
                    <span class="input-group-btn">
                        <button type="button" onclick="ShowSelTearch()" class="btn btn-primary">选择教师</button>
                    </span>
                </div>
                <input type="hidden" id="Manager_Hid" name="Manager_Hid" value="@Model.CreateUser" />
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>最大人数:</strong></td>
            <td>
                @Html.TextBoxFor(m => m.Integral, new { @class = "form-control text_s int", @value = "100" })
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>是否毕业:</strong></td>
            <td>
                <input type="checkbox" class="switchChk" id="IsDone" name="IsDone" @(Model.IsDone == 1 ? "checked='checked'" : "") />
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>班级星级:</strong></td>
            <td>
                <div class="col-md-9" id="star_div">
                    <i class="staricon fa fa-star-o" data-val="1"></i>
                    <i class="staricon fa fa-star-o" data-val="2"></i>
                    <i class="staricon fa fa-star-o" data-val="3"></i>
                    <i class="staricon fa fa-star-o" data-val="4"></i>
                    <i class="staricon fa fa-star-o" data-val="5"></i>
                    <input type="hidden" id="star_hid" name="star_hid" value="@Model.ClassStar" />
                </div>
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>班级徽标:</strong></td>
            <td>
                @Html.TextBoxFor(m => m.Monitor, new { @class = "form-control text_300" })
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>是否审核:</strong></td>
            <td>
                <input type="checkbox" id="IsTrue" name="IsTrue" class="switchChk" @(Model.IsTrue == 1 ? "checked='checked'" : "") />
            </td>
        </tr>
        <tr>
            <td class="tdleft"><strong>班级介绍:</strong></td>
            <td>
                @Html.TextAreaFor(m => m.Classinfo, new { @class = "form-control", @style = "width:443px;height:168px;" })
            </td>
        </tr>
        <tr>
            <td colspan="2" class="text-center">
                <button type="submit" class="btn btn-primary">确认添加</button>
                <a href="ClassRoomManage" class="btn btn-primary">返回列表</a>
            </td>
        </tr>
    </table>
</form>
}
@section script{
    <script type="text/javascript" src="/dist/js/bootstrap-switch.js"></script>
    <script type="text/javascript" src="/JS/ZL_Regex.js"></script>
    <script type="text/javascript" src="/JS/Controls/ZL_Dialog.js"></script>
    <script type="text/javascript" src="/JS/Plugs/IconSelector.js"></script>
    <script>
        $(function () {
            ZL_Regex.B_Num('.int');
            var iconsel = new iconSelctor("Monitor");
            StarByVal(@Model.ClassStar);
            validate.zl_init($("form"), {
                rules: {
                    RoomName: { required: true },
                    SchoolName_T: { required: true },
                    Integral: { required: true, digits: true }
                },
                messages: {
                    RoomName: { required: "班级名称不能为空" },
                    SchoolName_T: { required: "学校名称不能为空" },
                    Integral: { required: "最大人数不能为空", digits: "人数只能为整数" }
                },
            }, { placement: 'right', style: 'green' });
        })
        function StarInit() {
            $(".staricon").hover(function () {
                //fa-star-o空心,
                $(this).removeClass("fa-star-o").addClass("fa-star");
                $(this).prevAll(".staricon").removeClass("fa-star-o").addClass("fa-star");
            }, function () {
                StarByVal($("#star_hid").val());
            }).click(function () {
                $("#star_hid").val($(this).data("val"));
                StarByVal($(this).data("val"));
            });
            //移出div块,除非已click,否则清除值
            $("#star_div").mouseleave(function () {
                var val = $("#star_hid").val();
                StarByVal(val);
            });
        }
        //根据val点亮或熄灭评星
        function StarByVal(val) {
            if (val == "" || val == 0 || val == "0") { $(".staricon").removeClass("fa-star").addClass("fa-star-o"); }
            else
            {
                var ref = $(".staricon[data-val=" + val + "]"); ref.removeClass("fa-star-o").addClass("fa-star");
                ref.prevAll().removeClass("fa-star-o").addClass("fa-star");
                ref.nextAll().removeClass("fa-star").addClass("fa-star-o");
            }
        }
        //提交检测数据
        function CheckData() {
            if ($("#txtRoomName").val().trim() == "") { alert("班级名称不能为空!"); $("#txtRoomName").focus(); return false; }
            return true;
        }
        function GetTearcher(id, username) {
            $("#Manager_T").val(username);
            $("#Manager_Hid").val(id);
            teachDiag.CloseModal();
        }
        function CloseDiag() {
            teachDiag.CloseModal();
        }
        var teachDiag = new ZL_Dialog();
        function ShowSelTearch() {
            teachDiag.width = "none";
            teachDiag.maxbtn = false;
            teachDiag.reload = true;
            teachDiag.title = "选择教师";
            teachDiag.url = "/User/Exam/SelTearcher";
            teachDiag.width = "width1100";
            teachDiag.ShowModal();
        }
        //选择图标
        function ShowIcon() {
            comdiag.ajaxurl = "/Common/icon2.html";
            comdiag.title = "选择奥森图标";
            comdiag.ShowModal();
        }
        function LoadIcon() {
            $("[name=glyphicon]").click(function () {
                $("#Monitor").val($(this).prev().prev().attr("class"));
                $("#imgIcon").attr("class", $(this).prev().prev().attr("class"));
                CloseComDiag();
            });
        }
        //选择学校
        function ShowSchool() {
            teachDiag.url = "/User/Exam/SelSchool";
            teachDiag.title = "选择学校";
            teachDiag.reload = true;
            teachDiag.maxbtn = false;
            teachDiag.width = "width1100";
            teachDiag.ShowModal();
        }
        function CloseDiag() {
            teachDiag.CloseModal();
        }
        function GetSchoolName(name) {
            $("#SchoolName_T").val(name);
            teachDiag.CloseModal();
        }
    </script>
}